package com.hhw.servlet;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.hhw.entity.User;
import com.hhw.service.UpdateUserService;

/**
 * Servlet implementation class DoUpdate
 */
@WebServlet("/DoUpdate")
public class DoUpdate extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public DoUpdate() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		String user_id=request.getParameter("user_id");
		String username=request.getParameter("username");
		String sex=request.getParameter("sex");
		String phone=request.getParameter("phone");
		String add=request.getParameter("add");
		
		System.out.println(user_id+username+sex+phone+add);
		
		UpdateUserService uus = new UpdateUserService();
		User u = new User(Integer.parseInt(user_id),username,sex,phone,add);
		boolean b =uus.updateUser(u);
		
		request.getRequestDispatcher("tousermanage").forward(request, response);
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
